import datetime

import paramiko

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
private_key = paramiko.RSAKey.from_private_key_file(r"C:\Users\mg\.ssh\xb187.pem")
username = 'root'
host = '47.99.182.0'
client.connect(host, username=username, pkey=private_key)
stdin, stdout, stderr = client.exec_command('cd /project/xb_bot/xb_bot && sh ./deploy.sh')
print(stdout.read().decode('utf-8'))
client.close()
print(datetime.datetime.now(), '后端项目部署完成')


client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
private_key = paramiko.RSAKey.from_private_key_file(r"C:\Users\mg\.ssh\xb187.pem")
username = 'root'
host = '47.97.63.212'
client.connect(host, username=username, pkey=private_key)
stdin, stdout, stderr = client.exec_command('cd /project/xb_bot/xb_bot && sh ./deploy-newuser.sh')
print(stdout.read().decode('utf-8'))
client.close()
print(datetime.datetime.now(), '新客后端项目部署完成')

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
private_key = paramiko.RSAKey.from_private_key_file(r"C:\Users\mg\.ssh\xb187.pem")
username = 'root'
host = '115.29.215.108'
client.connect(host, username=username, pkey=private_key)
stdin, stdout, stderr = client.exec_command('cd /project/xb_bot/xb_bot && sh ./deploy-consumer.sh')
print(stdout.read().decode('utf-8'))
client.close()
print(datetime.datetime.now(), '消费后端项目部署完成')


client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
private_key = paramiko.RSAKey.from_private_key_file(r"C:\Users\mg\.ssh\xb187.pem")
username = 'root'
host = '8.136.96.253'
client.connect(host, username=username, pkey=private_key)
stdin, stdout, stderr = client.exec_command('cd /project/xb_bot/xb_bot && sh ./deploy-newuser.sh')
print(stdout.read().decode('utf-8'))
client.close()
print(datetime.datetime.now(), '上传后端项目部署完成')
